<?php

/*
 * Shinobi/Loader/Loader.php
 */

namespace Shinobi\Loader;

class Loader {
    
    /**
     * Autoload du Système
     * 
     * @param string $className
     * @return boolean
     */
    function autoloadSystem($className) {
        $className = ltrim($className, '\\');
        $fileName = '';
        $namespace = '';
        if ($lastNsPos = strripos($className, '\\')) {
            $namespace = substr($className, 0, $lastNsPos);
            $className = substr($className, $lastNsPos + 1);
            $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
        }
        $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
        $file = SYSTEM_PATH .$fileName;
        if(!file_exists($file)){
            return false;
        }
        require $file;
    }
}
